package com.hqq.concurrency.semaphone;

import java.util.ArrayList;
import java.util.List;

/**
 * FruitBowl
 * Created by heqianqian on 2017/7/30.
 */
public class FruitBowl {

    private List<Fruit> fruitList = new ArrayList<>();

    public int countFruit() {
        return fruitList.size();
    }

    public void put(Fruit fruit) {
        fruitList.add(fruit);
    }

    public Fruit get() {
        if (fruitList.size() == 0) {
            return null;
        }
        return fruitList.remove(0);
    }

    @Override
    public String toString() {
        return "FruitBowl{" +
                "fruitList=" + fruitList +
                '}';
    }
}
